package com.google.android.gms.common;

import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable.Creator;
import android.util.Log;
import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable.Class;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable.Constructor;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable.Field;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable.Param;
import javax.annotation.Nullable;
import o.apc;
import o.ape;
import o.aps;
import o.apz;
import o.aqa;
import o.aqd;
import o.aqg;

@Class(creator = "GoogleCertificatesQueryCreator")
public final class zzj extends AbstractSafeParcelable {
    public static final Creator<zzj> CREATOR = new aqa();
    @Field(getter = "getAllowTestKeys", id = 3)
    private final boolean ˋ;
    @Field(defaultValue = "false", getter = "getIgnoreTestKeysOverride", id = 4)
    private final boolean ˎ;
    @Field(getter = "getCallingCertificateBinder", id = 2, type = "android.os.IBinder")
    @Nullable
    private final aps ˏ;
    @Field(getter = "getCallingPackage", id = 1)
    private final String ॱ;

    @Constructor
    public zzj(@Param(id = 1) String str, @Param(id = 2) @Nullable IBinder iBinder, @Param(id = 3) boolean z, @Param(id = 4) boolean z2) {
        this.ॱ = str;
        this.ˏ = ˋ(iBinder);
        this.ˋ = z;
        this.ˎ = z2;
    }

    public final void writeToParcel(Parcel parcel, int i) {
        IBinder iBinder;
        int ॱ = apc.ॱ(parcel);
        apc.ˎ(parcel, 1, this.ॱ, false);
        if (this.ˏ == null) {
            Log.w("GoogleCertificatesQuery", "certificate binder is null");
            iBinder = null;
        } else {
            iBinder = this.ˏ.asBinder();
        }
        apc.ˊ(parcel, 2, iBinder, false);
        apc.ˊ(parcel, 3, this.ˋ);
        apc.ˊ(parcel, 4, this.ˎ);
        apc.ˎ(parcel, ॱ);
    }

    @Nullable
    private static aps ˋ(@Nullable IBinder iBinder) {
        if (iBinder == null) {
            return null;
        }
        try {
            aps o_apz;
            aqg ˏ = ape.ˏ(iBinder).ˏ();
            byte[] bArr = ˏ == null ? null : (byte[]) aqd.ˋ(ˏ);
            if (bArr != null) {
                o_apz = new apz(bArr);
            } else {
                Log.e("GoogleCertificatesQuery", "Could not unwrap certificate");
                o_apz = null;
            }
            return o_apz;
        } catch (Throwable e) {
            Log.e("GoogleCertificatesQuery", "Could not unwrap certificate", e);
            return null;
        }
    }
}
